# Sometimes it is convenient to know which widget is the sender of the signal.
# For that purpose, PySide has a sender() method
# In this application, we will make two buttons. In the buttonClick() method we will determine which button was pressed.
# The result will be shown on a status bar

import sys
from PySide import QtGui, QtCore

class Window(QtGui.QMainWindow):
    def __init__(self):
        super(Window, self).__init__()

        self.setGeometry(300, 300, 290, 150)
        self.setWindowTitle('Event sender')
        self.statusBar().showMessage('Ready', 5000)

        btn1 = QtGui.QPushButton("Button 1", self)
        btn1.move(30, 50)
        btn2 = QtGui.QPushButton("Button 2", self)
        btn2.move(150, 50)

        btn1.clicked.connect(self.buttonClicked)
        btn2.clicked.connect(self.buttonClicked)


    def buttonClicked(self):
        sender = self.sender()
        self.statusBar().showMessage(sender.text() + ' was pressed')


if __name__ == "__main__":
    appObject = QtGui.QApplication(sys.argv)
    ex = Window()
    ex.show()
    sys.exit(appObject.exec_())
